#登录页面

from selenium.webdriver.common.by import By

from utils.webUtils import PageBase

class PageLogin(PageBase):
    url="/simple/login"
    loc_zanhao=By.NAME,"login_info"
    loc_pwd=By.NAME,"password"
    loc_loginButton=By.XPATH,"//input[@type='submit' and @value='登录']"
    loc_error=By.CLASS_NAME,"prompt"

    def __init__(self,driver,base_url):
        PageBase.__init__(self,driver,base_url)


    #打开网页
    def openUrl(self):
        self.open(PageLogin.url)

    #输入账号
    def input_zanhao(self,zanhao):
        self.input(PageLogin.loc_zanhao,zanhao)


    #输入密码
    def input_pwd(self,pwd):
        self.input(PageLogin.loc_pwd,pwd)

    #点击登录按钮
    def click_loginButton(self):
        self.click(PageLogin.loc_loginButton)

    #获取密码框的class属性的值
    def getPwdAttrClass(self):
        return self.getEleAttr(PageLogin.loc_pwd,"class")

    #获取错误提示div标签的文本内容
    def getErrorTipsDivText(self):
        return self.getEleText(PageLogin.loc_error)

    # 获取账号框的class属性的值
    def getZanhaoAttrClass(self):
        return self.getEleAttr(PageLogin.loc_zanhao, "class")


